
#ver := $(shell sed -ne "s/^\$$version = '\\(.*\\)';/\\1/p" trunk/salon25.user.js)
ver := $(shell sed -ne "s-^//[ 	]*@version[ 	]*\\(.*\\)-\\1-p" trunk/salon25.user.js)
verne := $(shell sed -ne "s-^//[ 	]*@version[ 	]*\\(.*\\)-\\1-p" trunk/salon25ne.user.js)

wiki/Funkcje.wiki: trunk/salon25.user.js build/salon25.xpi
	sed -ne '/^#summary Funkcje skryptu Salon25/,\#^<wiki:comment>Funkcje END</wiki:comment>#p' $< >$@
	svn diff $@
	@echo;echo
	@echo "#Do publikacji nowej wersji v${ver}:"
	@echo
	@echo "vim -c 'set encoding=utf-8' wiki/Aktualnosci.wiki"
	@echo "svn diff wiki | vim -c \"set encoding=utf-8\" -"
	@echo 
	@echo '(cd tools/dropbox && php upload.php `cat .dropbox.pass`)'
	@echo "make release"
	@echo 
	@echo "http://code.google.com/p/salon25/admin"
	@echo 
	@echo "vim trunk/salon25.user.js #Bump version number to the odd number (odd=bleeding edge/trunk release)"
	@echo 

ne: trunk/salon25ne.user.js
	@echo;echo
	@echo "#Do publikacji nowej wersji ne-v${verne}:"
	@echo
	@echo "svn diff wiki | vim -c \"set encoding=utf-8\" -"
	@echo 
	@echo "make nerelease"
	@echo 
	@echo "http://code.google.com/p/salon25/admin"
	@echo 
	@echo "vim trunk/salon25ne.user.js #Bump version number to the odd number (odd=bleeding edge/trunk release)"
	@echo 

XPI_STATIC := content/compileduserscript.js content/prefman.js content/xmlhttprequester.js content/script-compiler.js content/script-compiler-overlay.xul chrome.manifest install.rdf
build/salon25.xpi: trunk/salon25.user.js tools/salon25.xpi
	mkdir -p build build/src
	cd build/src; unzip ../../tools/salon25.xpi
	cat build/src/install.rdf | sed -e 's@\(<em:version>\).*\(</em:version>\)@\1${ver}\2@' >build/src/install.rdf.new
	mv build/src/install.rdf.new build/src/install.rdf
	cat $< >build/src/content/compileduserscript.js
	cd build/src; zip -r ../salon25.xpi `find -type f`
	rm -rf build/src


release: 
	echo "${ver}" > wiki/Wersja.wiki
	svn copy https://salon25.googlecode.com/svn/trunk https://salon25.googlecode.com/svn/tags/v${ver} -m "tag version ${ver}"
	svn del https://salon25.googlecode.com/svn/tags/latest -m 'remove previous latest tag'
	svn copy https://salon25.googlecode.com/svn/tags/v${ver} https://salon25.googlecode.com/svn/tags/latest -m 'add tag latest = ${ver}'
	svn ci wiki -m "Dokumentacja v${ver}"

nerelease: 
	echo "${verne}" > wiki/WersjaNE.wiki
	svn copy https://salon25.googlecode.com/svn/trunk https://salon25.googlecode.com/svn/tags/ne/v${verne} -m "tag NE version ${verne}"
	svn del https://salon25.googlecode.com/svn/tags/ne/latest -m 'remove previous NE latest tag'
	svn copy https://salon25.googlecode.com/svn/tags/ne/v${verne} https://salon25.googlecode.com/svn/tags/ne/latest -m 'add tag NE latest = ${verne}'
	svn ci wiki -m "Dokumentacja NE v${verne}"
